load("@rules_java//java:defs.bzl", "java_library")
load("//:cel_android_rules.bzl", "cel_android_library")

package(
    default_applicable_licenses = [
        "//:license",
    ],
    default_visibility = [
        "//common/types:__pkg__",
    ],
)

# Collection of CEL type implementations and type-inference related classes.

# keep sorted
CEL_TYPE_SOURCES = [
    "EnumType.java",
    "ListType.java",
    "MapType.java",
    "NullableType.java",
    "OpaqueType.java",
    "OptionalType.java",
    "ProtoMessageType.java",
    "SimpleType.java",
    "StructType.java",
    "StructTypeReference.java",
    "TypeParamType.java",
    "TypeType.java",
]

# keep sorted
CEL_INTERNAL_TYPE_SOURCES = [
    "UnspecifiedType.java",
]

# keep sorted
CEL_TYPE_PROVIDER_SOURCES = [
    "CelKind.java",
    "CelType.java",
    "CelTypeProvider.java",
]

java_library(
    name = "types",
    srcs = CEL_TYPE_SOURCES,
    tags = [
    ],
    deps = [
        ":type_providers",
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "cel_internal_types",
    srcs = CEL_INTERNAL_TYPE_SOURCES,
    deps = [
        ":type_providers",
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "cel_types",
    srcs = ["CelTypes.java"],
    tags = [
    ],
    deps = [
        ":type_providers",
        ":types",
        "//common/annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "cel_proto_types",
    srcs = ["CelProtoTypes.java"],
    tags = [
    ],
    deps = [
        ":cel_internal_types",
        ":cel_types",
        ":type_providers",
        ":types",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

cel_android_library(
    name = "cel_proto_types_android",
    srcs = ["CelProtoTypes.java"],
    tags = [
    ],
    deps = [
        ":cel_internal_types_android",
        ":cel_types_android",
        ":type_providers_android",
        ":types_android",
        "@cel_spec//proto/cel/expr:checked_java_proto_lite",
        "@maven_android//:com_google_guava_guava",
        "@maven_android//:com_google_protobuf_protobuf_javalite",
    ],
)

java_library(
    name = "cel_proto_message_types",
    srcs = ["CelProtoMessageTypes.java"],
    tags = [
    ],
    deps = [
        ":cel_proto_types",
        "@cel_spec//proto/cel/expr:checked_java_proto",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "cel_v1alpha1_types",
    srcs = ["CelV1AlphaTypes.java"],
    tags = [
    ],
    deps = [
        ":type_providers",
        ":types",
        "//common/annotations",
        "@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

java_library(
    name = "json",
    srcs = ["JsonType.java"],
    tags = [
    ],
    deps = [
        ":type_providers",
        ":types",
        "//:auto_value",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "type_providers",
    srcs = CEL_TYPE_PROVIDER_SOURCES,
    tags = [
    ],
    deps = [
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "message_type_provider",
    srcs = [
        "ProtoMessageTypeProvider.java",
    ],
    tags = [
    ],
    deps = [
        ":cel_types",
        ":type_providers",
        ":types",
        "//:auto_value",
        "//common:cel_descriptors",
        "//common/internal:file_descriptor_converter",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_protobuf_protobuf_java",
    ],
)

cel_android_library(
    name = "cel_types_android",
    srcs = ["CelTypes.java"],
    tags = [
    ],
    deps = [
        "//common/annotations",
        "//common/types:type_providers_android",
        "//common/types:types_android",
        "@maven_android//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "type_providers_android",
    srcs = CEL_TYPE_PROVIDER_SOURCES,
    tags = [
    ],
    deps = [
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "types_android",
    srcs = CEL_TYPE_SOURCES,
    tags = [
    ],
    deps = [
        ":type_providers_android",
        "//:auto_value",
        "//common/annotations",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven_android//:com_google_guava_guava",
    ],
)

cel_android_library(
    name = "cel_internal_types_android",
    srcs = CEL_INTERNAL_TYPE_SOURCES,
    deps = [
        "//:auto_value",
        "//common/annotations",
        "//common/types:type_providers_android",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)
